package wiiusej.apptest.statistics;

import java.io.IOException;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.Priority;
import org.apache.log4j.PropertyConfigurator;

import wiiusej.Wiimote;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;





public class AccelerationPaquetsPerSecond implements Callable {
	
	static Logger fileLogger;
	static Logger fileLoggerTime;
	static Logger fileLoggerAcc;
	
	static Logger fileLoggerAccX;
	static Logger fileLoggerAccY;
	static Logger fileLoggerAccZ;
	
	
	private static final String fileURL = "src/test/java/wiiusej/apptest/statistics/logs/AccDataPaquets";
	private static final String fileURLTime = "src/test/java/wiiusej/apptest/statistics/logs/Time";
	private static final String fileURLAcc = "src/test/java/wiiusej/apptest/statistics/logs/Acceleration";
	
	private static final String fileURLAccX = 
		"src/test/java/wiiusej/apptest/statistics/logs/AccelerationX";
	
	private static final String fileURLAccY = 
		"src/test/java/wiiusej/apptest/statistics/logs/AccelerationY";
	
	private static final String fileURLAccZ = 
		"src/test/java/wiiusej/apptest/statistics/logs/AccelerationZ";
	
	
	private final MotionSensingEvent incomingEvent;
	//private static CopyOnWriteArrayList<AccelerationPaquet> eventList; 
	
		
	Vector<AccelerationPaquet> myEventVector 
		= new Vector<AccelerationPaquet>();
	
	private AccelerationPaquetList packetList;
	
	private PacketWraped myPackets; 
	
	
	private ArrayList<Integer> paquetsPerPeriod 
		= new ArrayList<Integer>();		
	
	private Date lastDateKey;
	
	private final int NANOS_FACTOR = 1000000;
	private final int TIME_PERIOD = 500; //in nanos
	
	private AccelerationPaquet temporal;
	
	public AccelerationPaquetsPerSecond(MotionSensingEvent event, 
			Long id, Long random, PacketWraped myPackets){		
		
		this.incomingEvent = event;
		//this.myEventVector = (Vector<AccelerationPaquet>) myPackets.getPackets().clone();		
		this.myPackets = myPackets;
		this.temporal = myPackets.getTemporal();
		this.myEventVector = myPackets.getMyEventVector().getPackets();
		this.packetList = myPackets.getMyEventVector();
		wakeUpLogStats(id, random);		
	}

	
	private void wakeUpLogStats(long id, long random) {
		
		PropertyConfigurator.configure("log4j.properties");	
		
		fileLoggerAccX = Logger.getLogger("statisticsAccX");	
		fileLoggerAccY = Logger.getLogger("statisticsAccY");
		fileLoggerAccZ = Logger.getLogger("statisticsAccZ");
		
		PatternLayout pattern1 = 
			new PatternLayout("%m%n");	
		
		try{
			
			FileAppender fileappendAccX=new FileAppender(pattern1,fileURLAccX + "_" + id + 
					"_" + random + ".log");
			
			fileappendAccX.setThreshold(Priority.DEBUG);			
			fileLoggerAccX.addAppender(fileappendAccX);
			

			FileAppender fileappendAccY=new FileAppender(pattern1,fileURLAccY + "_" + id + 
					"_" + random + ".log");
			fileappendAccY.setThreshold(Priority.DEBUG);			
			fileLoggerAccY.addAppender(fileappendAccY);
			

			FileAppender fileappendAccZ=new FileAppender(pattern1,fileURLAccZ + "_" + id + 
					"_" + random + ".log");
			fileappendAccZ.setThreshold(Priority.DEBUG);			
			fileLoggerAccZ.addAppender(fileappendAccZ);
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		fileLogger = Logger.getLogger("statistics");
		fileLoggerTime = Logger.getLogger("statisticsTime");
		fileLoggerAcc = Logger.getLogger("statisticsAcc");	
		
		PatternLayout pattern = 
			new PatternLayout("%m%n");		
		
		try {		
			//Creating a file for every connected wiimote
			FileAppender fileappend=new FileAppender(pattern,fileURL + "_" + id + ".log");
			fileappend.setThreshold(Priority.DEBUG);			
			fileLogger.addAppender(fileappend);
			
			FileAppender fileappendTime=new FileAppender(pattern,fileURLTime + "_" + id + 
					"_" + random + ".log");
			
			fileappendTime.setThreshold(Priority.DEBUG);			
			fileLoggerTime.addAppender(fileappendTime);
			
			FileAppender fileappendAcc=new FileAppender(pattern,fileURLAcc + "_" + id + ".log");
			fileappendAcc.setThreshold(Priority.DEBUG);			
			fileLoggerAcc.addAppender(fileappendAcc);			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}


	@Override
	public PacketWraped call() throws Exception {	
		
		
		takeStats();
		
		//fileLoggerAccX.info(incomingEvent.getRawAcceleration().getX());
		SimpleDateFormat tsFormat = new SimpleDateFormat("mm:ss:SS");
		
		Timestamp now = incomingEvent.getTime();		
		Timestamp now2 = new Timestamp(System.currentTimeMillis());
		
		int accX = incomingEvent.getRawAcceleration().getX();
		int accY = incomingEvent.getRawAcceleration().getY();
		int accZ = incomingEvent.getRawAcceleration().getZ();
		
		AccelerationPaquet newPaquet = new AccelerationPaquet(incomingEvent.getTime());
				
		
		fileLogger.info("Incoming EventTime: " + tsFormat.format(now) + 
				" RealTime: " + tsFormat.format(now2));
		
		
		if(myEventVector.isEmpty() && temporal.getTime() == null){
			
			fileLogger.info("Event Vector EMPTY");
			/*
			myPackets.setTemporal(new AccelerationPaquet(incomingEvent.getTime()));
			setElementTime(myPackets.getTemporal());*/
			
			temporal = new AccelerationPaquet(incomingEvent.getTime());
			setElementTime(temporal);
			
			temporal.uploadCounter();			
			addAccelerations(temporal, accX, accY, accZ);			
			
			//myEventVector.add(temporal);
			
			myPackets.setTemporal(temporal);
			
			fileLogger.info("Creating temporal: " + myPackets.getTemporal().getCounter() + 
					" Time: " + tsFormat.format(myPackets.getTemporal().getTime()));
			
			fileLogger.info("");
			return myPackets;
			
		}else{					
			
			temporal = myPackets.getTemporal();
			//fileLogger.info("Event Vector IS NOT empty");
			
			fileLogger.info("EventVector: " + myEventVector.size() + 
					" Temporal: " + tsFormat.format(myPackets.getTemporal().getTime()));
			
			
			int minuteRest = now.getMinutes() - temporal.getTime().getMinutes();
			int secondRest = now.getSeconds() - temporal.getTime().getSeconds();
			
			//MOD feedbacktime: 500 ms			
			boolean samePeriod = sameHalfPeriod(now);			
			
			fileLogger.info("MinuteRest: " + minuteRest + " SecondRest: " + secondRest + 
					" Same Period: " + samePeriod);
			
			if((secondRest==0) && (minuteRest==0) && samePeriod){				
				//wait until insert the new element
				temporal.uploadCounter();
				addAccelerations(temporal, accX, accY, accZ);
				myPackets.setTemporal(temporal);
				
				fileLogger.info("Same Period: " + temporal.getTime() + 
						" IncomingEvent: " + tsFormat.format(now));
				
				fileLogger.info("Uploading Temporal Time: " + tsFormat.format(myPackets.getTemporal().getTime())
				+ " Counter: " + myPackets.getTemporal().getCounter());
				
			}else{
				//here we have to make the insertion
				//temporal = new AccelerationPaquet(incomingEvent.getTime());
				myEventVector.add(temporal);
				
				fileLogger.info("Adding Temporal To EventVector - Temporal:" 
						+ tsFormat.format(myPackets.getTemporal().getTime())
						+ " Counter: " + myPackets.getTemporal().getCounter());
				
				temporal = new AccelerationPaquet(incomingEvent.getTime());
				setElementTime(temporal);
				addAccelerations(temporal, accX, accY, accZ);
				temporal.uploadCounter();
				myPackets.setTemporal(temporal);
				
				fileLogger.info("New Temporal Packet: " + tsFormat.format(myPackets.getTemporal().getTime()));
			}
			
			fileLogger.info("");
			
			return myPackets;
		}
	
		//return myEventVector;
		
		/*
		
		if(myEventVector.isEmpty()){		
			return checkFirtsPaquet(newPaquet, accX, accY, accZ, tsFormat);			
		}else{					
			
			AccelerationPaquet lastElement =  myEventVector.lastElement();
			Date lastDate = myEventVector.lastElement().getTime();
			
			int minuteRest = now.getMinutes() - myEventVector.lastElement().getTime().getMinutes();
			int secondRest = now.getSeconds() - myEventVector.lastElement().getTime().getSeconds();	
						
			//MOD feedbacktime: 500 ms			
			boolean samePeriod = sameHalfSecond(now);
			
			if( (secondRest==0) && (minuteRest==0) && samePeriod){
					
				lastElement.uploadCounter();
				addAccelerations(lastElement, accX, accY, accZ);
				
				fileLogger.debug("******************************************************");
				fileLogger.info("Same HalfSecond - Incoming Event TimeStamp: " + tsFormat.format(now));
				
				return myEventVector;
				
			}
			else{
				
				//NEW ADDITION
				newPaquet.uploadCounter();
				addAccelerations(newPaquet, accX, accY, accZ);
				
				//modify last element time
				setLastTime();
				
				myEventVector.add(newPaquet);	
			}
			
			/*
			else if((secondRest==0) && (minuteRest==0) && !samePeriod){
				//They are consecutive
				
				//NEW ADDITION
				newPaquet.uploadCounter();
				addAccelerations(newPaquet, accX, accY, accZ);
				
				//modify last element time
				setLastTime();
				
				myEventVector.add(newPaquet);				
				
				fileLogger.debug("******************************************************");
				fileLogger.info("HalfSecond Consecutive - Incoming Event TimeStamp: " 
						+ tsFormat.format(now));					
				
				return myEventVector;				
			}*/
			
			
			
			/*
			if( (now.getMinutes() != myEventVector.lastElement().getTime().getMinutes()) || 
					(now.getSeconds() != myEventVector.lastElement().getTime().getSeconds()) ){
								
				//we need to check if they are consecutive			
						
				boolean consecutivePeriod = consecutiveHalfSecond(now);
				
				//Second and Minute consecutive Paquets
				if((minuteRest == 0) && (secondRest == 1) && consecutivePeriod){
					
					newPaquet.uploadCounter();
					addAccelerations(newPaquet, accX, accY, accZ);

					//modify last element time
					setLastTime();
					
					myEventVector.add(newPaquet);
					
					
					
					fileLogger.debug("******************************************************");
					fileLogger.info("HalfSecond Consecutive Paquet - Incoming Event TimeStamp: " 
							+ tsFormat.format(now));					
					
					return myEventVector;
				}				
						
				//Minute Consecutive Second Non-Consecutive
				if( (minuteRest == 0) && (secondRest >= 1) && !consecutivePeriod){
					
					fileLogger.debug("******************************************************");
					fileLogger.info(" Non-Consecutive HalfSecond Paquet - Incoming: " 
							+ tsFormat.format(incomingEvent.getTime())
							+ " ListSize: " + myEventVector.size());									
					
					//modify last element time
					setLastTime();
					
					//fillUntilEnd(secondRest-1, aux);
					fillUntilEnd();					
					
					newPaquet.uploadCounter();					
					addAccelerations(newPaquet, accX, accY, accZ);					
					myEventVector.add(newPaquet);				
					
					return myEventVector;
					
				
				//Minute Non-Consecutive Paquets
				}else if(minuteRest > 0){					
										
					setLastTime();
					
					fileLogger.debug("******************************************************");
					fileLogger.debug(" Non-Consecutive Minute Paquet - Incoming: " 
							+ tsFormat.format(incomingEvent.getTime()));
					
					//boolean consecutiveMinute = minuteConsecutvie(now);
					
					for(int i = 1; i <= minuteRest+1; i++){
						
						Timestamp aux = (Timestamp) lastElement.getTime().clone();
						aux.setMinutes(aux.getMinutes());
						
						if(i == 1){							
							//first minute to be completed							
							fileLogger.debug("### Fullfilling LAST Minute: " + aux.getMinutes() + 
									" LastElement: " + myEventVector.lastElement().getTime().getSeconds());
							fillUntilEnd();			
						}
								
														
				}
				
					
					if( (incomingEvent.getTime().getSeconds() > 0)
							|| incomingEvent.getTime().getSeconds() == 0 && 
							incomingEvent.getTime().getNanos()/NANOS_FACTOR > 500){						
						countPaquetsPerMinute();
						addFirstElement();
						fillUntilEnd();
						
					}else{
						//first element is next minute with 00:00 seconds
					}			
				
					//put new element into the list
					newPaquet.uploadCounter();
					addAccelerations(newPaquet, accX, accY, accZ);
					
					myEventVector.add(newPaquet);					
					printReport(lastElement, tsFormat, lastDate);
				
					//fileLogger.info("List size: " + myArray.size());
					return myEventVector;
				
				//Same Second Paquets
			}
			}*/			
			
			
		
		
	}
	
	private void takeStats(){		
		SimpleDateFormat tsFormat = new SimpleDateFormat("mm:ss:SS");
		
		Timestamp now = incomingEvent.getTime();
		
		fileLoggerAccX.info(incomingEvent.getRawAcceleration().getX());
		fileLoggerAccY.info(incomingEvent.getRawAcceleration().getY());	
		fileLoggerAccZ.info(incomingEvent.getRawAcceleration().getZ());	
		fileLoggerTime.info(tsFormat.format(now));
	}
	
	private void setElementTime(AccelerationPaquet packet){
		
		if(packet.getTime().getNanos()/NANOS_FACTOR < 500){			
			packet.getTime().setNanos(0);
			
		}else{
			packet.getTime().setNanos(501*NANOS_FACTOR);
			
		}
		
	}
	
	private void setLastTime(){
		
		if(myEventVector.lastElement().getTime().getNanos()/NANOS_FACTOR < 500){			
			fileLogger.info("*** Time modified - FROM: " + myEventVector.lastElement().getTime());
			myEventVector.lastElement().getTime().setNanos(0);
			fileLogger.info("*** TO: " + myEventVector.lastElement().getTime());
		}else{
			fileLogger.info("*** Time modified - FROM: " + myEventVector.lastElement().getTime());
			myEventVector.lastElement().getTime().setNanos(501*NANOS_FACTOR);
			fileLogger.info("*** TO: " + myEventVector.lastElement().getTime());
		}
		
	}
	
	
	private boolean minuteConsecutvie(Timestamp now){
		
		if(incomingEvent.getTime().getSeconds() == 59
				&& now.getSeconds() == 0){
			return true;
			
		}
		
		
		return false; 
	}
	
	private boolean consecutiveHalfSecond(Timestamp now) {		
		if( (myEventVector.lastElement().getTime().getNanos()/NANOS_FACTOR - 500) > 1 
				&& now.getNanos()/NANOS_FACTOR - 500 < 1){
			return true;
		}		
		
		return false;
	}

	private boolean sameHalfPeriod(Timestamp now){
		
		
		if( ((now.getNanos()/NANOS_FACTOR < 500) && 
				(temporal.getTime().getNanos()/NANOS_FACTOR) < 500)){			
			return true;
			
		}else if((now.getNanos()/NANOS_FACTOR >= 500) && 
				(temporal.getTime().getNanos()/NANOS_FACTOR) >= 500){
			return true;
		}
		return false;	
		
	}

	/*
	private boolean sameHalfSecond(Timestamp now) {
		
		if( ((now.getNanos()/NANOS_FACTOR < 500) && 
				(myEventVector.lastElement().getTime().getNanos()/NANOS_FACTOR) < 500)){			
			return true;
			
		}else if((now.getNanos()/NANOS_FACTOR >= 500) && 
				(myEventVector.lastElement().getTime().getNanos()/NANOS_FACTOR) >= 500){
			return true;
		}
		return false;		
	}*/


	private Vector<AccelerationPaquet> checkFirtsPaquet(AccelerationPaquet newPaquet, int accX, 
			int accY, int accZ, SimpleDateFormat tsFormat) {
		
		newPaquet.uploadCounter();			
		addAccelerations(newPaquet, accX, accY, accZ);			
		
		myEventVector.add(newPaquet);			
		
		fileLogger.debug("FIRST PAQUET: " + 
				tsFormat.format(incomingEvent.getTime()) + 
				" Acceleration: " + newPaquet +
				" ListSize: " + myEventVector.size());	
		
		fileLogger.debug("PaquetsInSecond: " + myEventVector.lastElement().getCounter()
				+ "Second: " + incomingEvent.getTime().getSeconds());
		
		return myEventVector;
		
	}


	private void checkPerformance() {

		AccelerationPaquet newPaquet = new AccelerationPaquet(incomingEvent.getTime());
				
		
		SimpleDateFormat tsFormat = new SimpleDateFormat("mm:ss:SS");
		
		if(myEventVector.isEmpty()){
			fileLogger.info("FIRST PAQUET: " + newPaquet.getTime());
			//newPaquet.uploadCounter();			
			myEventVector.add(newPaquet);
			
		}
		
		if(!myEventVector.isEmpty()){
			fileLogger.debug("*************************************************************************");
			fileLogger.debug("IncomingEvent: " + tsFormat.format(incomingEvent.getTime()));
			fileLogger.debug("PaquetsInSecond: " + myEventVector.lastElement().getCounter());
			fileLogger.debug("Last Element: " + tsFormat.format(myEventVector.lastElement().getTime()));
			
			
			myEventVector.add(newPaquet);
		}
			
		
	}


	private double calculeMean(){				
		double size = myEventVector.size();		
		double counter = 0; 
				
		for(AccelerationPaquet aux : myEventVector){			
			paquetsPerPeriod.add(aux.getCounter());
			counter+= aux.getCounter();			
		}		
		return (double) counter/size;		
	}
	
	private void printReport(AccelerationPaquet lastElement, SimpleDateFormat tsFormat2, Date lastDate){
		//Report last timestamp
		fileLogger.info("######################################################################");
		fileLogger.info("LIST REPORT - " +	"ListSize: " + myEventVector.size());
		
		SimpleDateFormat tsFormat = new SimpleDateFormat("mm:ss:SS");
		
		
		double mean = calculeMean();				
		fileLogger.info("Mean: " + mean );				
		
		for(AccelerationPaquet aux : myEventVector){
			fileLogger.info(tsFormat.format(aux.getTime()) + " Paquets: " + aux.getCounter());			
			//fileLoggerTime.info(tsFormat2.format(aux.getTime()));
			//fileLoggerAcc.info(aux.getCounter());			
		}		
		fileLogger.info("######################################################################");		
		
		
		//fileLoggerTime.info("_____________________________________________________________");
		//fileLoggerAcc.info("****************************************************************");
		//fileLoggerAcc.info(" ");
	}
	
	private void fillUntilEnd(){		
		
		int minRest = incomingEvent.getTime().getMinutes() - myEventVector.lastElement().getTime().getMinutes(); 
		
		Timestamp aux = (Timestamp) myEventVector.lastElement().getTime().clone();
		
		int endSecond = calculeEnd();		
		
		fileLogger.info("### Seconds To be Filled: " + calculeEnd());		
		
		for(int i = 0; i < endSecond; i++){			
			fillSeconds(aux);				
			aux = (Timestamp) myEventVector.lastElement().getTime().clone();							
		}
			
				
	}
	
	private void fillSeconds(Timestamp last){
		
		Timestamp incoming;
		Timestamp next;
		
		int minuteRest = incomingEvent.getTime().getMinutes() - last.getMinutes();
		
		if(minuteRest >= 1){	
			incoming = (Timestamp) last.clone();
			incoming.setSeconds(59);
			incoming.setNanos(501*NANOS_FACTOR);			
		}else{
			 incoming = (Timestamp) incomingEvent.getTime().clone();
		}
		
		
		int secondRest = incoming.getSeconds() -	last.getSeconds();
		
		fileLogger.info("#### Filling seconds - " + " LastElementSecond: " + last 
				+ " Incoming: " + incoming + " SecondRest: " + secondRest);
		
		if( last.getNanos()/NANOS_FACTOR == 0 ){
			
			//We need to add the second half paquet into this time period
			last.setNanos(501 * NANOS_FACTOR);
			AccelerationPaquet nextToLast = new AccelerationPaquet(last);
			myEventVector.add(nextToLast);	
			fileLogger.info("#### Adding second slot time period - NextToLast: " + last);
			
		}else if( last.getNanos()/NANOS_FACTOR == 501 ){
			//We need to add the next half second slots into the next time period (second)
			if(secondRest > 1){				
				last.setSeconds(last.getSeconds()+1);
				last.setNanos(0);
				AccelerationPaquet nextToLast = new AccelerationPaquet(last);
				myEventVector.add(nextToLast);	
				fileLogger.info("#### Adding first half-second of next timeperiod - NextToLast: " + last);
					
				last = (Timestamp) myEventVector.lastElement().getTime().clone();
			
				last.setNanos(501 * NANOS_FACTOR);
				AccelerationPaquet nextToLast2 = new AccelerationPaquet(last);
				myEventVector.add(nextToLast2);	
				fileLogger.info("#### Adding second half-second of same timeperiod - NextToLast: " + last);				
			}else{
				//we are in the last minute and we need to check if we should add one or two slot time				
				if(incoming.getNanos()/NANOS_FACTOR > 500){
					last.setSeconds(last.getSeconds()+1);
					last.setNanos(0);
					AccelerationPaquet nextToLast = new AccelerationPaquet(last);
					myEventVector.add(nextToLast);	
					fileLogger.info("#### Adding first half-second of next timeperiod - NextToLast: " + last);
					
					if(incoming.getSeconds() == 59 && incoming.getNanos()/NANOS_FACTOR > 500 && 
							minuteRest > 0){
						//add the last one
						AccelerationPaquet lastPaquet = new AccelerationPaquet(incoming);
						myEventVector.add(lastPaquet);
						fileLogger.info("#### Adding LAST: " + incoming);						
					}					
				}			
			}				
		}			
	}
	
	private int calculeEnd(){
		
		Timestamp incoming;
		Timestamp last = (Timestamp) myEventVector.lastElement().getTime().clone();				
		int minuteRest = incomingEvent.getTime().getMinutes() - last.getMinutes();
				
		if(minuteRest >= 1){	
			incoming = (Timestamp) last.clone();
			incoming.setSeconds(59);
			incoming.setNanos(501*NANOS_FACTOR);			
		}else{
			 incoming = (Timestamp) incomingEvent.getTime().clone();
		}
		
		int secondRest = incoming.getSeconds() - last.getSeconds();
		
		if( last.getNanos()/NANOS_FACTOR > 500 && 
				incoming.getNanos()/NANOS_FACTOR > 500){			
			return secondRest;			
		}
		
		if(last.getNanos()/NANOS_FACTOR > 500 && 
				incoming.getNanos()/NANOS_FACTOR <= 500){
			
			return secondRest-1;
			
		}
		
		if(last.getNanos()/NANOS_FACTOR <= 500 && 
				incoming.getNanos()/NANOS_FACTOR <= 500){
			
			return secondRest;
			
		}
		
		if(last.getNanos()/NANOS_FACTOR <= 500 && 
				incoming.getNanos()/NANOS_FACTOR > 500){
			
			return secondRest+1;
			
		}
		
		return secondRest;
	}
	
	
	private void addFirstElement(){
		
		Timestamp firstElement = (Timestamp) incomingEvent.getTime().clone();
		firstElement.setSeconds(0);
		firstElement.setNanos(0);
		
		AccelerationPaquet newPaquet = new AccelerationPaquet(firstElement);		
		myEventVector.add(newPaquet);
	}
	
	private void addAccelerations(AccelerationPaquet newPaquet, int accX, int accY, int accZ){
		newPaquet.addAccX(accX);
		newPaquet.addAccY(accY);
		newPaquet.addAccZ(accZ);		
	}
	
	private void countPaquetsPerMinute(){
		
		int accXNumber = 0;
		int accYNumber = 0;
		int accZNumber = 0;
		
		for(AccelerationPaquet  aux : myEventVector){
			accXNumber = accXNumber + aux.getAccX().size();
			accYNumber = accYNumber + aux.getAccY().size();			
			accZNumber = accZNumber + aux.getAccZ().size();			
		}
		
		fileLoggerTime.info("Minute: " + myEventVector.lastElement().getTime().getMinutes()
				+ " Paquets: " + myEventVector.size() +
				" AccValues: [" + accXNumber + "," + accYNumber + "," + accZNumber );
		
		
	}
	
}
